package com.lunwen.lunwen.services.impl;

import com.lunwen.lunwen.bean.MuBan;
import com.lunwen.lunwen.mapper.MuBanMapper;
import com.lunwen.lunwen.services.MuBanService;
import org.springframework.stereotype.Service;

import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

/**
 * (MuBan)表服务实现类
 *
 * @author makejava
 * @since 2020-07-24 12:30:06
 */
@Service
public class MuBanServiceImpl implements MuBanService {

    @Autowired
    private MuBanMapper muBanMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param mubanId 主键
     * @return 实例对象
     */
    @Override
    public MuBan queryById(String mubanId) {
        return this.muBanMapper.queryById(mubanId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<MuBan> queryAllByLimit(MuBan muBan, int offset, int limit) {
        return this.muBanMapper.queryAllByLimit(muBan.getMubanmingcheng(),
                                                muBan.getXueyuanId(),
                                                muBan.getZhuanyeId(),
                                                muBan.getZhuangtai(),
                                                muBan.getShuoming(),
                                                offset, limit);
    }

    @Override
    public int queryCount(MuBan muBan) {
        return muBanMapper.queryCount(muBan);
    }

    /**
     * 新增数据
     *
     * @param muBan 实例对象
     * @return 实例对象
     */
    @Override
    public MuBan insert(MuBan muBan) {
        this.muBanMapper.insert(muBan);
        return muBan;
    }

    /**
     * 修改数据
     *
     * @param muBan 实例对象
     * @return 实例对象
     */
    @Override
    public MuBan update(MuBan muBan) {
        this.muBanMapper.update(muBan);
        return this.queryById(muBan.getMubanId());
    }

    /**
     * 通过主键删除数据
     *
     * @param mubanId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String mubanId) {
        return this.muBanMapper.deleteById(mubanId) > 0;
    }
}